# Contributor: Carlo Landmeter <clandmeter@gmail.com>
# Maintainer: Fathi Boudra <fathi.boudra@linaro.org>
pkgname=uboot-tools
pkgver=2020.04
pkgrel=0
pkgdesc="U-Boot bootloader utility tools"
url="https://www.denx.de/wiki/U-Boot/WebHome"
arch="all !s390x !ppc64le"
license="GPL"
makedepends="$depends_dev bison flex openssl-dev linux-headers"
subpackages="$pkgname-examples"
options="!check" # No test suite
source="http://ftp.denx.de/pub/u-boot/u-boot-$pkgver.tar.bz2
	fix-ulong-typedef.patch
	defang-efi-bootcmd.patch
	"
builddir="$srcdir/u-boot-$pkgver"

build() {
	cd "$builddir"
	make defconfig
	make tools-all
}

examples() {
	mkdir -p "${subpkgdir}/usr/share/doc/${pkgname}"
	mv "${pkgdir}/usr/share/doc/${pkgname}/examples/" \
	   "${subpkgdir}/usr/share/doc/${pkgname}"
}

package() {
	cd "$builddir"
	for tool in bmp_logo dumpimage env/fw_printenv \
		fit_check_sign fit_info gdb/gdbcont gdb/gdbsend gen_eth_addr img2srec \
		mkenvimage mkimage ncb proftool ubsha1 xway-swap-bytes env/fw_printenv; do
			install -D tools/$tool \
				$pkgdir/usr/bin/$(basename $tool)
	done
	install -Dm644 tools/env/fw_env.config \
	        "${pkgdir}/usr/share/doc/${pkgname}/examples/fw_env.config"
	cd "$pkgdir"/usr/bin
	ln -sf fw_printenv fw_setenv
}

sha512sums="e04fe54883149123730605b084324ac0d1d72ce6913467bbe587a5a2675bcf7bb393405d9a446dc0c64ba42abc1e862ae5a132e9e51aa7390e2e9fce045af8d8  u-boot-2020.04.tar.bz2
813dd152afa8863d3c7456449c9b0b358232edae7c8575ebe4af71bfe74019d4c27f30dc6fcf307018e36f5afdaf7de32253c0a773955d5be74c625ddd5668c7  fix-ulong-typedef.patch
ae4fa0a1e11fe862fc30d78d52616ede65b87893e656d7bca0c3e269d744ed477a23185f1d61e91e9beb765c5bafcbcba65699ca9835a516637098ef332644df  defang-efi-bootcmd.patch"
